home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 24
/
AMIGAplus Sonderheft 24 (2000)(Falke)(DE)[!].iso
/
Rexx
/
InvoiceText.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-06
|
5KB
|
222 lines
/*
InvoiceText.rexx
$VER: 13 Jan 1998
*/
arg iNameCode
options results
/* Initialize */
Quote = '22'x
cInvoice = 0
DataPath = "S:TimeKeep/"
if iNameCode = "" then do
Say ""
Say "ERROR: No Client Code"
Say ""
exit
end
/* Read Time Data */
if ~ open('Time', DataPath||iNameCode||".time", 'R') then do
Say ""
Say "ERROR: .time NOT FOUND"
Say ""
exit
end
t = readln('Time')
parse var t '"'Client.NameCode'","'Client.Name'"'
/* Collate */
Projects = "|"; nProjects = 0 ; Expenses = 0; Work = 0
do while ~eof('Time')
t = readln('Time')
parse var t '"'tType'","'tProject'",'tInfo
if tInfo == "" then leave
if index(Projects, "|"tProject"|") = 0 then do
/* Project not found */
Projects = Projects||tProject"|"
nProjects = nProjects + 1
Projects.nProjects.Name = tProject
if tType = "T" then do
Projects.nProjects.count = 1
Expenses.nProjects.count = 0
end
else do
Projects.nProjects.count = 0
Expenses.nProjects.count = 1
end
cProject = nProjects; n = 1
end
else do
/* Project exists */
do lp = 1 to nProjects
if Projects.lp.Name = tProject then leave
end
cProject = lp
if tType = "T" then do
Projects.lp.count = Projects.lp.count + 1
n = Projects.lp.count
end
else do
Expenses.lp.count = Expenses.lp.count + 1
n = Expenses.lp.count
end
end
if tType = "T" then do
Projects.cProject.n.Info = tInfo
Work = 1
end
else do
Expenses.cProject.n.Info = tInfo
Expenses = 1
end
end
call close('Time')
if nProjects = 0 then do
Say ""
Say "ERROR: NO Logged Time or Expenses"
Say ""
exit
end
/* Read Invoice Number */
if open('Invoice', DataPath||Client.NameCode||".invoice", 'R') then do
cInvoice = readln('Invoice')
call close('Invoice')
end
cInvoice = cInvoice + 1
Client.Invoice = right(cInvoice, 2, "0")
/* Create Invoice */
call open('Out', DataPath"/TimeKeep/Invoice."Client.NameCode''Client.Invoice, 'W')
/* Invoice # */
call writeln('Out', "Invoice #"Client.NameCode''Client.Invoice)
/* Client Name */
'Type' Client.Name
call writeln('Out', Client.Name)
call writeln('Out', "")
/* Date */
call writeln('Out', date())
call writeln('Out', "")
call writeln('Out', "")
/* Work Description */
call writeln('Out', "== WORK ===============================")
call writeln('Out', "")
/* Work Description - Projects */
do lp = 1 to nProjects
if Projects.lp.Name ~= "" then do
call writeln('Out', " "Projects.lp.Name)
call writeln('Out', " -")
end
end
/* Expenses */
TotalExpenses = 0
if Expenses then do
call writeln('Out', "")
call writeln('Out', "== EXPENSES ===========================")
call writeln('Out', "")
do lp = 1 to nProjects
if Expenses.lp.count = 0 then iterate
call writeln('Out', " "Projects.lp.Name)
do lp2 = 1 to Expenses.lp.count
t = Expenses.lp.lp2.Info
if index(t, '","', index(t, '","')+3) = 0 then do
parse var t '"'tInfo'","'tAmount'"'
call writeln('Out', " "tInfo" "tAmount)
end
else do
parse var t '"'tInfo'","'tQuantity'","'tPer'","'tAmount'"'
call writeln('Out', " "tInfo" ("tQuantity" @ "tPer") "tAmount)
end
TotalExpenses = TotalExpenses + tAmount
end
end
call writeln('Out', "")
call writeln('Out', " EXPENSES: $"TotalExpenses)
end
Total = 0
if Work then do
call writeln('Out', "")
/* Work Hours */
call writeln('Out', "== WORK HOURS =========================")
call writeln('Out', "")
do lp = 1 to nProjects
if Projects.lp.count = 0 then iterate
call writeln('Out', " "Projects.lp.Name)
HSubTotal = 0
do lp2 = 1 to Projects.lp.count
parse var Projects.lp.lp2.Info '"'tDate'","'tT1'","'tT2'","'tH'","'tRate'"'
call writeln('Out', " "tDate" "tT1" - "tT2" "tH)
HSubTotal = HSubTotal + tH
end
SubTotal = trunc(HSubTotal * tRate + .5e-2, 2)
call writeln('Out', " "HSubTotal" @ $"tRate" / hour: "SubTotal)
Total = Total + SubTotal
end
call writeln('Out', "")
call writeln('Out', " WORK: $"Total)
end
call writeln('Out', "")
call writeln('Out', "=======================================")
call writeln('Out', "")
Total = Total + TotalExpenses
call writeln('Out', " TOTAL: $"Total)
call writeln('Out', "")
call writeln('Out', "=======================================")
call writeln('Out', "")
call writeln('Out', "Payment To:")
call writeln('Out', "")
call writeln('Out', "dhomas trenn")
call writeln('Out', "797 Mitchell Street, Fredericton, NB E3B 3S8")
call writeln('Out', "(506) 459-7088")
call close('Out')
/* Write Invoice Number */
call open('Invoice', DataPath||Client.NameCode||".invoice", 'W')
call writeln('Invoice', cInvoice)
call close('Invoice')
/* Backup .time data file */
ADDRESS COMMAND 'C:Rename' DataPath||Client.NameCode||".time" DataPath||Client.NameCode||".time."Client.Invoice
exit